//
//  WithdrawalsViewController.m
//  Manage
//
//  Created by 杨康 on 2017/11/23.
//  Copyright © 2017年 杨康. All rights reserved.
//

#import "WithdrawalsViewController.h"
#import <AlipaySDK/AlipaySDK.h>
@interface WithdrawalsViewController ()
@property(nonatomic,strong)ykTableView *tableView;
@end

@implementation WithdrawalsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"提现管理";
    
    UIButton *leftButton=(UIButton *)self.navigationItem.leftBarButtonItem.customView;
    leftButton.selected=YES;
    
    
    UIButton *rightButton=[NetworkPath SetNavRightBtnWithController:self withTitle:@"筛选" andImageName:nil];
    rightButton.selected=YES;
    [rightButton addTarget:self action:@selector(rightAction) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    UISearchBar *searchBar=[[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44)];
    
    
    searchBar.placeholder=@"搜索手机号";
    searchBar.backgroundImage=[NetworkPath createImageWithColor:[UIColor colorF]];
    
    [[UISearchBar appearance] setSearchFieldBackgroundImage:[self searchFieldBackgroundImage] forState:UIControlStateNormal];
    UITextField *txfSearchField = [searchBar valueForKey:@"_searchField"];
    [txfSearchField setDefaultTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13.5]}];
    
    searchBar.searchTextPositionAdjustment = UIOffsetMake(7, 0);
    
    
    
    
    
    self.tableView=[SingLeton myTableViewWithFrame:CGRectMake(0, TOP_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT-TOP_HEIGHT) withRefresh:NO didSelect:^(ykTableView *tableView, NSIndexPath *indexPath) {
        
    }];
    [self.view addSubview:self.tableView];
    self.tableView.tableHeaderView=searchBar;
    
    
    
    
    self.tableView.className=@"RepairerCell";
    NSMutableArray *itemArr=[NSMutableArray array];
    
    
    for (int i=0; i<5; i++) {
        repairerData *dataObj=[[repairerData alloc]init];
        dataObj.image=@"";
        dataObj.text=@"修理商名称";
        dataObj.address=@"我家在东北松花江上啊我家在东北松花江上啊";
        [itemArr addObject:dataObj];
        
        
        
    }
    [self.tableView.dataArray addObject:itemArr];
    [self.tableView reloadData];
    
    
    
}
//调用方法
- (UIImage*)searchFieldBackgroundImage {
    UIColor*color = [UIColor whiteColor];
    CGFloat cornerRadius = 5;
    CGRect rect =CGRectMake(0,0,28,28);
    
    UIBezierPath*roundedRect = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:cornerRadius];
    roundedRect.lineWidth=0;
    
    UIGraphicsBeginImageContextWithOptions(rect.size,NO,0.0f);
    [color setFill];
    [roundedRect fill];
    [roundedRect stroke];
    [roundedRect addClip];
    
    UIImage *image =UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}
-(void)rightAction
{
//    //将商品信息赋予AlixPayOrder的成员变量
//    Order* order = [Order new];
//    
//    // NOTE: app_id设置
//    order.app_id = appID;
//    
//    // NOTE: 支付接口名称
//    order.method = @"alipay.trade.app.pay";
//    
//    // NOTE: 参数编码格式
//    order.charset = @"utf-8";
//    
//    // NOTE: 当前时间点
//    NSDateFormatter* formatter = [NSDateFormatter new];
//    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
//    order.timestamp = [formatter stringFromDate:[NSDate date]];
//    
//    // NOTE: 支付版本
//    order.version = @"1.0";
//    
//    // NOTE: sign_type设置
//    order.sign_type = @"RSA";
//    
//    // NOTE: 商品数据
//    order.biz_content = [BizContent new];
//    order.biz_content.body = @"我是测试数据";
//    order.biz_content.subject = @"1";
//    order.biz_content.out_trade_no = [self generateTradeNO]; //订单ID（由商家自行制定）
//    order.biz_content.timeout_express = @"30m"; //超时时间设置
//    order.biz_content.total_amount = [NSString stringWithFormat:@"%.2f", 0.01]; //商品价格
//    
//    //将商品信息拼接成字符串
//    NSString *orderInfo = [order orderInfoEncoded:NO];
//    NSString *orderInfoEncoded = [order orderInfoEncoded:YES];
//    NSLog(@"orderSpec = %@",orderInfo);
//    
//    // NOTE: 获取私钥并将商户信息签名，外部商户的加签过程请务必放在服务端，防止公私钥数据泄露；
//    //       需要遵循RSA签名规范，并将签名字符串base64编码和UrlEncode
//    id<DataSigner> signer = CreateRSADataSigner(privateKey);
//    NSString *signedString = [signer signString:orderInfo];
//    
//    // NOTE: 如果加签成功，则继续执行支付
//    if (signedString != nil) {
//        //应用注册scheme,在AliSDKDemo-Info.plist定义URL types
//        NSString *appScheme = @"alisdkdemo";
//        
//        // NOTE: 将签名成功字符串格式化为订单字符串,请严格按照该格式
//        NSString *orderString = [NSString stringWithFormat:@"%@&sign=%@",
//                                 orderInfoEncoded, signedString];
//        
//        // NOTE: 调用支付结果开始支付
//        [[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) {
//            NSLog(@"reslut = %@",resultDic);
//        }];
//    }
}


@end
